package operation;

import book.Book;
import book.BookList;

public class FindOperation implements IOperation{
    public void work(BookList bookList) {
        System.out.println("查找图书");
        System.out.println("请输入你要查找的书的书名：");
        String name = scanner.nextLine();
        int size = bookList.getUseSide();
        int i = 0;
        for (; i < size; i++) {
            Book book = bookList.getBook(i);
            if (name.equals(book.getName())) {
                System.out.println("找到了，信息如下：");
                System.out.println(book);
                break;
            }
        }
        if (i >= size) {
            System.out.println("没有你要找的书");
        }
    }
}
